package com.leef.oauth.util;

import android.content.SharedPreferences;

import com.leef.oauth.App;

/**
 * Created by IWALL on 2016/8/24.
 * SharePreference
 */
public class SharePrefsUtils {

    private static final String TAG = "SharePrefsUtils";

    //  ---- get ----
    public static boolean getBoolean(String key, boolean value) {
        return App.getApplication().getSharePreference().getBoolean(key, value);
    }

    public static int getInt(String key, int value) {
        return App.getApplication().getSharePreference().getInt(key, value);
    }

    public static long getLong(String key, long value) {
        return App.getApplication().getSharePreference().getLong(key, value);
    }


    public static String getString(String key, String value) {
        return App.getApplication().getSharePreference().getString(key, value);
    }

    //  ---- set ----
    public static void setValue(String key, boolean value) {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.putBoolean(key, value).apply();
    }

    public static void setValue(String key, int value) {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.putInt(key, value).apply();
    }

    public static void setValue(String key, long value) {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.putLong(key, value).apply();
    }

    public static void setValue(String key, String value) {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.putString(key, value).apply();
    }

    public static void remove(String key) {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.remove(key).apply();
    }

    //  ---- clear ----
    public static void clear() {
        SharedPreferences.Editor editor = App.getApplication().getSharePreference().edit();
        editor.clear().apply();
    }

}
